package com.idbk.chargestation.bean;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

/**
 * 充电点详情Json
 * @author liangzw,lupc
 */

public class JsonPoint extends JsonBase implements Parcelable {

	public final static String KEY = JsonPoint.class.getSimpleName();
	
	@SerializedName("id")
	public int id;
	
	@SerializedName("name")
	public String name;
	
	@SerializedName("address")
	public String address;
	
	@SerializedName("lat")
	public double lat;
	
	@SerializedName("lng")
	public double lng;
	
	@SerializedName("isCollection")
	public boolean isCollection;//当前用户是否收藏 
	
	@SerializedName("isOpening")
	public boolean isOpen;
	
	@SerializedName("isOnline")
	public boolean isOnline;//是否在线
	
	@SerializedName("isFree")
	public boolean isFree;//是否免费
	
	@SerializedName("total")
	public int total;//充电桩总数目
	
	@SerializedName("idleNum")
	public int idleNum;
	
	@SerializedName("operatorId")
	public int operatorId;//运营商Id
	
	@SerializedName("imageURLs")
	public List<String> imageURLs;//图片地址,最大容量5

	@SerializedName("mark")
	public String mark;//充电点平均评分
		
	@SerializedName("priceInfo")
	public String priceInfo;//第三方充电点费用信息
	
	@SerializedName("serviceFee")
	public boolean serviceFee;//是否收取服务费用
	
	@SerializedName("contactNum")
	public String contactNum;//联系电话
	
	@SerializedName("notes")
	public String notes;//第三方充电点备注信息
		
	@SerializedName("operatorName")
	public String operatorName;//运营商名称
	
	@SerializedName("operatorCompany")
	public String operatorCompany;//运营商公司全称
	
	@SerializedName("operatorLogoImage")
	public String operatorLogoImage;//运营商LOGOURL
	
	@SerializedName("servicePhone")
	public String servicePhone;//运营商咨询电话

	@SerializedName("pointDetails")
	public List<JsonPointPile> pointDetails;//充电桩列表

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(id);
		dest.writeString(name);
		dest.writeString(address);
		dest.writeDouble(lat);
		dest.writeDouble(lng);
		boolean[] a = new boolean[5];
		a[0] = isCollection;
		a[1] = isOpen;
		a[2] = isOnline;
		a[3] = isFree;
		a[4] = serviceFee;
		dest.writeBooleanArray(a);
		dest.writeInt(idleNum);
		dest.writeInt(operatorId);		
		dest.writeStringList(imageURLs);
		dest.writeString(mark);
		dest.writeString(priceInfo);
		
		dest.writeString(contactNum);
		dest.writeString(notes);
		dest.writeString(operatorName);
		dest.writeString(operatorCompany);
		dest.writeString(operatorLogoImage);
		dest.writeString(servicePhone);
		
		if(pointDetails == null || pointDetails.size() < 1){
			dest.writeInt(0);
		} else {
			dest.writeInt(pointDetails.size());
			dest.writeTypedList(pointDetails);
		}
		
	}
	
	public final static Parcelable.Creator<JsonPoint> CREATOR = new Creator<JsonPoint>() {

		@Override
		public JsonPoint[] newArray(int size) {
			// TODO Auto-generated method stub
			return new JsonPoint[size];
		}

		@Override
		public JsonPoint createFromParcel(Parcel source) {
			// TODO Auto-generated method stub
			return new JsonPoint(source);
		}
	};
	
	public JsonPoint(Parcel in) {
		
		id = in.readInt();
		name = in.readString();
		address = in.readString();
		lat = in.readDouble();
		lng = in.readDouble();
				
		boolean[] a = new boolean[5];
		in.readBooleanArray(a);
		
		isCollection = a[0];
		isOpen = a[1];
		isOnline = a[2];
		isFree = a[3];
		serviceFee = a[4];
		
		idleNum = in.readInt();
		operatorId = in.readInt();
		imageURLs = new ArrayList<String>();
		in.readStringList(imageURLs);
		
		mark = in.readString();
		priceInfo = in.readString();
		
		contactNum = in.readString();
		notes = in.readString();
		operatorName = in.readString();
		operatorCompany = in.readString();
		operatorLogoImage = in.readString();
		servicePhone = in.readString();
		
		int size = in.readInt();
		if(size < 1){
			pointDetails = null;
		} else {
			pointDetails = new ArrayList<JsonPointPile>(size);
			in.readTypedList(pointDetails, JsonPointPile.CREATOR);
		}
		
	}

}
